Namespace Component

    Partial Public Class ColorPicker

        ''' <summary>
        ''' Color item listed in ColorPicker.
        ''' </summary>
        ''' <remarks></remarks>
        Public Class ColorItem

            ''' <summary>
            ''' Item kind.
            ''' </summary>
            ''' <remarks></remarks>
            Public Enum ColorItemKind
                ''' <summary>
                ''' Normal item.
                ''' </summary>
                ''' <remarks></remarks>
                Normal = 0
                ''' <summary>
                ''' Default color item.
                ''' </summary>
                ''' <remarks></remarks>
                [Default] = 1
                ''' <summary>
                ''' Custom color item.
                ''' </summary>
                ''' <remarks></remarks>
                Custom = 2
            End Enum

            Private m_Color As Drawing.Color 'Color object of the item.
            Private m_Kind As ColorItemKind 'Kind of the item.

            ''' <summary>
            ''' Color object of the item.
            ''' </summary>
            ''' <value>Set the color object of the item.</value>
            ''' <returns>Get the color object of the item.</returns>
            ''' <remarks></remarks>
            Public Property Color() As Drawing.Color
                Get
                    Return Me.m_Color
                End Get
                Set(ByVal value As Drawing.Color)
                    Me.m_Color = value
                End Set
            End Property

            ''' <summary>
            ''' Get the kind of the item.
            ''' </summary>
            ''' <value></value>
            ''' <returns></returns>
            ''' <remarks></remarks>
            Public ReadOnly Property Kind() As ColorItemKind
                Get
                    Return Me.m_Kind
                End Get
            End Property

            ''' <summary>
            ''' Constructor.
            ''' </summary>
            ''' <param name="color">Color object of the item.</param>
            ''' <param name="kind">Kind of the item.</param>
            ''' <remarks></remarks>
            Public Sub New(ByVal color As Drawing.Color, ByVal kind As ColorItemKind)
                Me.m_Color = color
                Me.m_Kind = kind
            End Sub

            ''' <summary>
            ''' Get the color name displayed in the combo list.
            ''' </summary>
            ''' <returns>The color name displayed in the combo list.</returns>
            ''' <remarks>
            ''' In normal item, it return the name of the color object;
            ''' In custom or default item, it will return 'Custom' and 'Default' string constantly.
            ''' </remarks>
            Public Overrides Function ToString() As String
                Return IIf(Me.m_Kind = ColorItemKind.Normal, Me.m_Color.Name, Me.m_Kind.ToString)
            End Function

            ''' <summary>
            ''' Operator of CType to string.
            ''' </summary>
            ''' <param name="op1">Operate object.</param>
            ''' <returns>CType to string value.</returns>
            ''' <remarks></remarks>
            Public Shared Widening Operator CType(ByVal op1 As ColorItem) As String
                Return op1.ToString
            End Operator

        End Class

        Public Class SelectedColorChangedEventArgs
            Inherits EventArgs

            Private m_Color As Drawing.Color

            Public ReadOnly Property Color() As Drawing.Color
                Get
                    Return Me.m_Color
                End Get
            End Property

            Public Sub New(ByVal c As Drawing.Color)
                MyBase.New()
                Me.m_Color = c
            End Sub

        End Class

    End Class

End Namespace
